<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>音频播放</title>
  <link rel="stylesheet" href="font/iconfont.css">
  <script src="http://47.104.209.44/base/js/jquery-1.10.1.min.js"></script>
  <style>
  *{
    padding:0;
    margin:0;
  }
  html,body,.box{
    width:100%;
    height:100%;
  }
  .box{
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .playbtn{
    width:200px;
    height:200px;
    display: block;
    font-size: 160px;
    border:1px solid #999;
    border-radius: 50%;
    text-align: center;
    line-height: 200px;
    color:darkgoldenrod;
  }

  @keyframes move{
    from{
      transform: rotate(0deg);
    }
    to{
      transform: rotate(360deg);
    }
  }

  .move{
    animation: move 4s 0s infinite linear reverse;
  }
  .stop{
    animation-play-state: paused;
  }
  .play{
    animation-play-state: running;
  }

  </style>
  <!-- 
    垂直水平居中
    1. 
     position: absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
    margin:auto;
    2. 
    position: absolute;
    top:50%;
    left:50%;
    margin:-100px;
    3. 
    position: absolute;
    top:50%;
    left:50%;
    transform: translate(-50%,-50%);
    4.
    display: flex;
    justify-content: center;
    align-items: center;
    5.
   -->
</head>
<body>
    <audio id="myaudio" src="http://47.104.209.44/mp/Sugar.mp3" autoplay   loop  preload >
       当前浏览器不支持音频播放 
    </audio>

    <div class="box">
      <i class="iconfont icon-yinyue playbtn move" onclick="playtoggle()" ></i>
    </div>

    <script>
       var myaudio = document.getElementById("myaudio")
      function playtoggle(){
          // if(myaudio.paused){
          //   myaudio.play()
          // }else{
          //   myaudio.pause()
          // }
          myaudio.paused?myaudio.play() : myaudio.pause()
      }

      myaudio.addEventListener("play",function(){
        console.log("play")
        $(".playbtn").addClass("play").removeClass("stop");
      })

      myaudio.addEventListener("pause",function(){
        console.log("pause")
        $(".playbtn").addClass("stop").removeClass("play");
      })

      myaudio.addEventListener("loadedmetadata",()=>{
        myaudio.paused?$(".playbtn").addClass("stop").removeClass("play") : $(".playbtn").addClass("play").removeClass("stop")
      })
    </script>
</body>
</html>